package com.adm.biz;

import java.util.Map;

import org.yfsoft.comm.util.BizResult;

import com.adm.ctl.ResultType;
import com.adm.dao.CommonDao;

public class ControlService extends Service {

	private CommonDao dao = null;

	public void setDao( CommonDao dao) {
		this.dao = dao;
	}
	
	public BizResult list(Map<String,String> input){
		BizResult rst = this.dao.list("sys_control",null,null,null,100,0);
		rst.setType(String.valueOf(ResultType.REDIRECT));
		rst.setPage("control/list.jsp");
		this.setReqAttr("controls", rst.getData());
		return rst;
	}
	
	
	public BizResult add(Map<String,String> input){
		BizResult rst = this.dao.insert(input, "sys_control");
		if("0".equals(rst.getCode())){
			this.setReqAttr("msg", "OK");
		}else{
			this.setReqAttr("msg", rst.getMsg());
		}
		return list(input);
	}

	public BizResult del(Map<String,String> input){
		BizResult rst = new BizResult().setCode("0");
		rst.setType(String.valueOf(ResultType.REDIRECT));
		rst.setPage("model/add.jsp");
		return rst;
	}
	
	public BizResult addform(Map<String,String> input){
		BizResult rst = new BizResult().setCode("0");
		rst.setType(String.valueOf(ResultType.JUMP));
		rst.setPage("control/add.jsp");
		return rst;
	}
	
	public BizResult updform(Map<String,String> input){
		//TODO..获取值
		BizResult rst = new BizResult().setCode("0");
		rst.setType(String.valueOf(ResultType.REDIRECT));
		rst.setPage("model/upd.jsp");
		return rst;
	}
	
}
